package com.gs.core.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name="ACTION")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="ACTION_TYPE", discriminatorType=DiscriminatorType.STRING)
public abstract class Action {
	private Long id;
	private String description;
	private Long displayOrder;
	private Person actionPerformedBy;
	private Date performedAt;
	
	@Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="ACTION_ID", unique=true, nullable=false, scale=0)	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	@Column(name="DESCRIPTION")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	@Column(name="DISPLAY_ORDER")
	public Long getDisplayOrder() {
		return displayOrder;
	}

	public void setDisplayOrder(Long displayOrder) {
		this.displayOrder = displayOrder;
	}
	@ManyToOne
	@JoinColumn(name="PERSON_ID")
	public Person getActionPerformedBy() {
		return actionPerformedBy;
	}

	public void setActionPerformedBy(Person actionPerformedBy) {
		this.actionPerformedBy = actionPerformedBy;
	}
	
	@Temporal(value=TemporalType.DATE)
	@Column(name="PERFORMED_AT")
	public Date getPerformedAt() {
		return performedAt;
	}

	public void setPerformedAt(Date performedAt) {
		this.performedAt = performedAt;
	}
	
	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append(getDescription());
		return sb.toString();
	}
	
}
